<?php
declare(strict_types=1);

namespace app\store\controller\user;

use app\store\controller\Controller;
use think\App;
use think\db\exception\DbException;
use think\response\Json;
use app\store\service\user\Collect as CollectService;

/**
 * 盒柜
 */
class Collect extends Controller
{

    private $collectService;
    public function __construct(App $app,CollectService $collectService)
    {
        parent::__construct($app);
        $this->collectService = $collectService;
    }

    /**
     * 盒柜
     * @return Json
     * @throws DbException
     */
    public function index(): Json
    {
        $params = $this->request->get();
        $data = $this->collectService->getIndex($params);
        return $this->renderSuccess($data);
    }


    /**手动提货
     * @return Json
     */
    public function pickUp():Json
    {
        $params = $this->request->post();
        $this->validate(
            $params,
            [
                'collect_ids' => 'require',
            ]
        );
        $collect_ids = $params['collect_ids'];
        $res = $this->collectService->getPickUp($collect_ids);
        if(!$res){
            return $this->renderError('提货失败');
        }
        return $this->renderSuccess([],'操作成功');
    }


}